﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Globalization;

public partial class activate : System.Web.UI.Page
{
    ServerObject mServerObject = null;
    protected string stringGUID = string.Empty;

    protected override void InitializeCulture()
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(HttpContext.Current.Request.UserLanguages[0]);
        System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(HttpContext.Current.Request.UserLanguages[0]);

        base.InitializeCulture();
    }

    private bool CheckServerObject()
    {
        bool result = false;

        if (Session["ServerModule"] != null)
        {
            mServerObject = (ServerObject)Session["ServerModule"];
        }
        else
        {
            mServerObject = new ServerObject();
            Session["ServerModule"] = mServerObject;
        }

        if (mServerObject != null)
        {
            result = true;
        }

        return result;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckServerObject())
        {
            if (!IsPostBack)
            {
                stringGUID = Request.QueryString["refNumber"];
                GetRefNumber(stringGUID);
            }
        }
        else
        {
            //ShowPanel(stapeZeroPanel.ID);
        }
        
    }

    private void GetRefNumber(string stringGUID)
    {
        if (!string.IsNullOrEmpty(stringGUID))
        {
            bool resultActivate = mServerObject.CheckSolicitantiByGUID(stringGUID);
            if (resultActivate)
            {
                //redirect to login form
                Response.Redirect("logInPage.aspx?result=true");
            }
            else
            {
                //redirect to error form
                Response.Redirect("default.aspx");
            }
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }

    #region Web Form Designer generated code
    protected override void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }

    private void InitializeComponent()
    {
        this.Load += new System.EventHandler(this.Page_Load);
    }

    #endregion Web Form Designer generated code
}